package com.itheima.homework.homework06;

public class Produce extends Thread {
    private Warehouse warehouse;

    public Produce(Warehouse warehouse) {
        this.warehouse=warehouse;
    }
    @Override
    public void run() {
        while (true) {
            synchronized (warehouse.object) {
                if (warehouse.count >= 10) {

                } else {
                    warehouse.count++;
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("生产存入1个单位货物，现在仓库剩余" + warehouse.count);
                }
            }
        }
    }
}
